package calculator;

import java.util.ArrayList;
import java.util.List;

public class Stack
{

	private List<String>	stack;

	public Stack()
	{
		this.stack = new ArrayList<String>();
	}

	public void push(String element)
	{
		this.stack.add(element);
	}

	public String pop()
	{
		if(this.stack.size() == 0)
		{
			return null;
		}
		
		
		int lastIndex = this.stack.size() - 1;
		String oberesElement = this.stack.get(lastIndex);
		this.stack.remove(lastIndex); // weil in stack doubles sien koennen
		return oberesElement;
	}

	public String toString()
	{
		return this.stack.toString();
	}
	
	
	public static void main(String[] args)
	{
		Stack s = new Stack();
		System.out.println(s);
		s.push("a");
		System.out.println(s);
		s.push("b");
		System.out.println(s);
		s.push("c");
		System.out.println(s);
		System.out.println(s.pop());
		System.out.println(s);
		System.out.println(s.pop());
		System.out.println(s);
		System.out.println(s.pop());
		System.out.println(s);
		
		System.out.println(s.pop());
		System.out.println(s);
	}

}
